<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form action="http://www.baidu.com">
    <input type="submit" value="免费注册">
  </form>
  <a href="http://www.baidu.com">百度一下</a>

</body>

<script>
  // 阻止上面两个对象的默认行为
  let a = document.querySelector(`a`);
  a.addEventListener(`click`,function(a){
    alert(`6`);
    a.preventDefault();
  })
</script>

</html>